JavaScript is required to use Bungie.net

Forums

originally posted in:BungieNetPlatform
originally posted in: New App using new Authentication
Edited by Hamilton420: 12/21/2016 12:00:45 AM
2
Hello! Great work on your app! I have downloaded the Android version and was able to login and use both modes successfully, no problems. I have shared this post with my friend who was exploring the idea of a similar application. He's an iPhone user so maybe he'll reach out to you for a Test Flight invite. [quote]I'm also aware there will be lots of people trying to write new Apps now and would be happy to offer help in implementing the new OAuth Login.[/quote] I would really love to see how you implemented the OAuth login in the Android app. I noticed as soon as I open the app I'm redirected to the browser to login, etc. which makes sense but I'm unsure how to achieve this flow (and handle the callback) from my Android app. Would you be willing to explain a bit further? I understand you might not want to share your code, but maybe pseudo code? Any help would be appreciated!
English

Posting in language:

 

Play nice. Take a minute to review our Code of Conduct before submitting your post. Cancel Edit Create Fireteam Post

  • Edited by Alex: 12/21/2016 5:04:05 PM
    [quote]Great work on your app! I have downloaded the Android version and was able to login and use both modes successfully, no problems. I have shared this post with my friend who was exploring the idea of a similar application. He's an iPhone user so maybe he'll reach out to you for a Test Flight invite.[/quote] Thanks! [quote]I would really love to see how you implemented the OAuth login in the Android app. I noticed as soon as I open the app I'm redirected to the browser to login, etc. which makes sense but I'm unsure how to achieve this flow (and handle the callback) from my Android app. Would you be willing to explain a bit further? I understand you might not want to share your code, but maybe pseudo code? Any help would be appreciated![/quote] Sure no problem! I use a Google Custom Tab to open the authentication link in App if they are running a newish version of Android using this code in my main Activity. [i]Uri uri = Uri.parse("https://www.bungie.net/en/Application/Authorize/1234567890"); [b]<--- your auth link here[/b] CustomTabsIntent.Builder intentBuilder = new CustomTabsIntent.Builder(); CustomTabsIntent customTabsIntent = intentBuilder.build(); customTabsIntent.launchUrl(this, uri);[/i] In my Manifest file I add some declarations to register a URL callback so that I get notified when the auth has complete. [i]<activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> <intent-filter> [b]<--- important section to add[/b] <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.BROWSABLE" /> <category android:name="android.intent.category.DEFAULT" /> <data android:scheme="yourURISchemeNameHere" /> </intent-filter> </activity>[/i] You then specify your redirect URL on Bungies Application page to "yourURISchemeNameHere://token" Then finally back in your main Activity's onCreate add this code: [i]Intent intent = getIntent(); Uri data = intent.getData(); if (data != null) { String uriString = data.toString(); }[/i] uriString will have the code within it as a URL parameter. Do some String parsing to look for code= and pull out the rest and this is your code to request your Access Token

    Posting in language:

     

    Play nice. Take a minute to review our Code of Conduct before submitting your post. Cancel Edit Create Fireteam Post

  • Amazing! This helped me a ton. I didn't realize I can just define a URI scheme in my manifest for the redirect. So thinking a bit forward, I'm wondering how to manage whether a user is authenticated already or not, so my app doesn't ask the user to "Allow" my application every time it's run. Should I just store the "code" I get back? But does this expire? etc.

    Posting in language:

     

    Play nice. Take a minute to review our Code of Conduct before submitting your post. Cancel Edit Create Fireteam Post

You are not allowed to view this content.
;
preload icon
preload icon
preload icon